import requests

# 1. 提取ip
headers = {
	'api-token': "60526a43ae1f7bcd1f1b6352f02d04bf",
	'api-id': "i3lnxvf"
}

res = requests.get("https://apis.ipfoxy.com/ip/open-api/proxy-list?page=1&page_size=10", headers=headers)

for item in res.json()["data"]["list"]:
	# print(item['host'], item['port'], item['user'], item['password'])
	ip = f"http://{item['user']}:{item['password']}@{item['host']}:{item['port']}"
	print(ip)

	proxies = {
		"http": "http://%(user)s:%(pwd)s@%(proxy)s/" % {'user': item['user'], 'pwd': item['password'], 'proxy': f"{item['host']}:{item['port']}"},
		"https": "http://%(user)s:%(pwd)s@%(proxy)s/" % {'user': item['user'], 'pwd': item['password'], 'proxy': f"{item['host']}:{item['port']}"}
	}

	res = requests.get("https://httpbin.org/get", proxies={
		"http": ip,
		"https": ip,
	})

	print(f"IP: {res.json()['origin']}")

	break
